package com.paging.controller;

import com.paging.pojo.Author;
import com.paging.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 位置：SSM/com.paging.controller
 * 时间：2023-04-25-16:20
 * 作者：Administrator
 **/

@Controller
public class AuthorController {

    @Autowired
    AuthorService authorService;

    @RequestMapping("/selectAuthorList")
    @ResponseBody
    public List<Author> queryAuthorList() {
        return  authorService.queryAuthorList();
    }

    @RequestMapping("/countAuthor")
    @ResponseBody
    public int countAuthor(String authorName, String authorSex) {
        return authorService.countAuthor(authorName,authorSex);
    }

    @RequestMapping("/addAuthor")
    @ResponseBody
    public int addAuthor(Author author) {
        return authorService.addAuthor(author);
    }

    @RequestMapping("/deleteAuthor")
    @ResponseBody
    public int deleteAuthor(int id) {
        return authorService.deleteAuthor(id);
    }

    @RequestMapping("/updateAuthor")
    @ResponseBody
    public int updateAuthor(Author author) {
       return authorService.updateAuthor(author);
    }

    @RequestMapping("/deleteAuthorByIds")
    @ResponseBody
    public int deleteAuthorByIds(String idList) {
        return authorService.deleteAuthorByIds(idList);
    }

    @RequestMapping("/queryAuthorListByPage")
    @ResponseBody
    public List<Author> queryAuthorListByPage(@RequestParam("page") Integer start, Integer pageSize, String authorName, String authorSex) {

        return authorService.queryAuthorListByPage(start,pageSize,authorName,authorSex);
    }



}
